from nets.yolo3 import yolo_body
from keras.layers import Input
from yolo import YOLO
from PIL import Image
import os


def picture():
    yolo = YOLO()
    path = os.getcwd()
    print(path)
    try:
        image = Image.open(path+'./static/uploadfiles/test_complete.jpg')
    except:
        print('\033[31m图片加载错误！请重试!')
    else:
        r_image,r_log1,r_log2,r_log3,r_log4 = yolo.detect_image(image)
        # r_image.show()
        r_image.save(path+'./static/uploadfiles/pre_complete.jpg')
    # yolo.close_session()
    return r_log1,r_log2,r_log3,r_log4

# picture()

# for i in range(1,6):
#     img = str(i)+'.jpg'
#     try:
#         image = Image.open('img/'+img)
#     except:
#         print('\033[31m图片加载错误！请重试!')
#         continue
#     else:
#         r_image = yolo.detect_image(image)
#         r_image.show()

# while True:
#     img = input('\033[0m输入图片名: ')
#     try:
#         image = Image.open('img/'+img)
#     except:
#         print('\033[31m图片加载错误！请重试!')
#         continue
#     else:
#         r_image = yolo.detect_image(image)
#         r_image.show()

# yolo.close_session()
